//
//  JYOrderDetaController.m
//  JYFarm
//
//  Created by 花花 on 2017/10/17.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "JYOrderDetaController.h"
#import "JYOrderDetaCell.h"
#import "JYOrderInfoCell.h"
@interface JYOrderDetaController ()

@property(nonatomic)JYOrderDetaView *detaView;

@property(nonatomic)NSArray *detaArr;

@property(nonatomic)NSArray *titleArr;
@end

static NSString *const JYOrderDetaCellID = @"JYOrderDetaCellID";
@implementation JYOrderDetaController

#pragma mark - Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"我的订单";
    
    [self setupTableView];


}
#pragma mark - setupTableView
- (void)setupTableView{

    self.tableView.tableHeaderView = self.detaView;
        [self.tableView registerClass:[JYOrderDetaCell class] forCellReuseIdentifier:JYOrderDetaCellID];
    self.detaView.dataArr = self.detaArr;
    /*
     JYOrderTypeAll = 0, // 全部
     JYOrderTypeObligation = 1, //待付款
     JYOrderTypeOverhang = 2, // 待发货
     JYOrderTypeReceive = 3, // 待收货
     JYOrderTypeCompleted = 4 // 已完成
     */
 
    UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, kBtnHeight+30)];
    UIButton *payBtn  =  [UIButton jy_buttontitle:@"确认支付" titleColor:kfColor frame:CGRectMake(10, 30, Screen_Width-20, kBtnHeight) target:self action:@selector(payOnClick) fontSize:17 bgImageName:@"login_button_background"];
    [footerView addSubview:payBtn];
    self.tableView.tableFooterView = footerView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

//    return self.titleArr.count+1;
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 10;


}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.row ==4) {
        return 30;
    }else if (indexPath.row ==5){
        return 66;
    }
    return kTableView_rowHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    JYOrderDetaCell *cell = [tableView dequeueReusableCellWithIdentifier:JYOrderDetaCellID];
    cell.leftLabel.text = [self.titleArr safeObjectAtIndex:indexPath.row];
    cell.rightLabel.text = @" -¥20.00";
    if (indexPath.row==1) {
        cell.rightLabel.textColor = [UIColor colorWithHexString:@"EF216B"];
        cell.rightLabel.text = @"-¥20.00";
    }else if(indexPath.row ==3){
        
        cell.rightLabel.font = kFont(14);
        cell.rightLabel.text = @"¥2680.00";
        cell.rightLabel.textColor = k3Color;
    }else if (indexPath.row == 4) {
        cell.leftLabel.textColor = k9Color;
        cell.backgroundColor = [UIColor colorWithHexString:@"F2F2F2"];
        cell.rightLabel.text = @"";
  
    }else if (indexPath.row==5){
    cell.leftLabel.numberOfLines = 0;
    cell.leftLabel.text = @"沈笑 13632200000\n上海市闵行区龙湖天街d栋701（龙门客栈)";
    cell.rightLabel.text = @"";
    cell.backgroundColor = [UIColor whiteColor];
    }
    return cell;
}

#pragma mark - SEL Methods
- (void)payOnClick{
    
    NSLog(@"确认支付");
    
}
#pragma mark - Setter && Getter Methods
- (JYOrderDetaView *)detaView{

    if (!_detaView) {
        _detaView = [[JYOrderDetaView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 360)];
    }
    return _detaView;

}
- (NSArray *)detaArr{

    if (!_detaArr) {
        _detaArr = @[@"12",@"232",@"12",@"232",@"12",@"232",@"12",@"232",@"12",@"232",@"12",@"232",@"12",@"232",@"12",@"232"];
    }
    return _detaArr;

}

- (NSArray *)titleArr{

    if (!_titleArr) {
        _titleArr = @[@"配送费",@"运费减免",@"押金",@"总计金额",@"注：最终以实际货物所需费用为准，多退少补"];
    }
    return _titleArr;

}



@end
